#include <iostream>
#include <vector>
#include <algorithm>
#include <sys/time.h>

using namespace std;




void moveZeroes(vector<int>& nums) 
{
  int size = nums.size();
  int end = size-1;

  if(end<=0)
  {
    return;
  }
  
  int tmp;
  int numberofZero=0;
  for(int i=0,j=0;i<end;++i)
  {
    if(nums[i]==0)
    {
      for( j=i+1;j<=end;++j)
      {
        if(nums[j]!=0)
        {
          nums[i]=nums[j];
          nums[j]=0;
          break;
        }
      }
      if(j>end)
        break;
    }

  }

}

int main(int argc,char *argv[])
{

  struct  timeval    tv1,tv2;
  struct  timezone   tz;
  int time1 = gettimeofday(&tv1,&tz);

  vector<int> nums={1,0};
   
  moveZeroes(nums);

  for(auto i:nums)
    cout<<i<<",";
  cout<<endl;

  int time2 = gettimeofday(&tv2,&tz);
  cout << "time consuming(local machine/leetcode server):"<<endl
    <<"leetcode server time consuming should be less than 500ms"<<endl
    << tv2.tv_usec - tv1.tv_usec <<"us/"<<0.11*( tv2.tv_usec - tv1.tv_usec )<<"ms"<< endl;



  return 0;
}
